using System;
using System.Data;
using System.Collections.Generic;

namespace shfa.snomtastic.data.business
{
    public partial class SubnetController
    {
		private SubnetInfo ObjectFromDataRow(DataRow dr)
        {
            if (dr != null)
            {
				SubnetInfo obj = new SubnetInfo();
				obj.SubnetId = dr.Field<Guid>("SubnetId"); 
				obj.ConfigurationId = (dr["ConfigurationId"] != DBNull.Value) ? dr.Field<Guid>("ConfigurationId") : Guid.Empty; 
				obj.IP = (dr["IP"] != DBNull.Value) ? dr.Field<String>("IP") : string.Empty; 
				obj.Mask = (dr["Mask"] != DBNull.Value) ? dr.Field<String>("Mask") : string.Empty; 
				obj.StartIP = (dr["StartIP"] != DBNull.Value) ? dr.Field<String>("StartIP") : string.Empty; 
				obj.EndIP = (dr["EndIP"] != DBNull.Value) ? dr.Field<String>("EndIP") : string.Empty; 
				obj.StartInt = (dr["StartInt"] != DBNull.Value) ? dr.Field<Int64>("StartInt") : -1; 
				obj.EndInt = (dr["EndInt"] != DBNull.Value) ? dr.Field<Int64>("EndInt") : -1; 
				return obj;
            }
            return null;
        }

        private List<SubnetInfo> ListFromDataTable(DataTable dt)
        {
            List<SubnetInfo> lst = new List<SubnetInfo>();

            foreach (DataRow dr in dt.Rows)
            {
                lst.Add(ObjectFromDataRow(dr));
            }

            return lst;
        }
    }
}
